﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Data.SqlClient;

namespace BHair.Report
{
    public partial class 积分流水表 : WeifenLuo.WinFormsUI.Docking.DockContent
    {
        public 积分流水表()
        {
            InitializeComponent();
        }
        string constr = ConfigurationManager.ConnectionStrings["BHair.Properties.Settings.BHairDBConnectionString"].ConnectionString;
        private void 积分流水表_Load(object sender, EventArgs e)
        {
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text==string.Empty) {
                SqlConnection conn = new SqlConnection(constr);
                conn.Open();
                string str = string.Format("SELECT * FROM [积分表] where [消费日期]>='{0}' and [消费日期]<='{1}'", dateTimePicker1.Text, dateTimePicker2.Text);
                SqlDataAdapter sda = new SqlDataAdapter(str, conn);
                DataTable dt = new DataTable();
                sda.Fill(dt);
                this.dataGridView1.DataSource = dt;
                conn.Close();
            }
            else
            {
                SqlConnection conn = new SqlConnection(constr);
                conn.Open();
                string str = string.Format("SELECT * FROM [积分表] where [消费日期]>='{0}' and [消费日期]<='{1}' and 卡号='{2}'", dateTimePicker1.Text, dateTimePicker2.Text,textBox1.Text);
                SqlDataAdapter sda = new SqlDataAdapter(str, conn);
                DataTable dt = new DataTable();
                sda.Fill(dt);
                this.dataGridView1.DataSource = dt;
                conn.Close();
            }
        }
    }
}
